﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using JXMSTC2.Model;
using JXMSTC2.Control;

public partial class EduApplicant : System.Web.UI.Page
{
    int classID;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["classID"] != null)//帮顶班级名称
            {
                classID = Convert.ToInt16(Request["classID"]);
                NewClassModelControl clscon = new NewClassModelControl();
                JXMSTC2.Model.NewClass cls = clscon.GetModel(classID);
                this.txtClass.Text = cls.ClassName;
            }
            else
            {
                Response.Redirect("Default.aspx");
            }
        if (!IsPostBack)
        {
            ListBind();
            

        }
    }

    #region 按钮点击
    protected void btnOK_Click(object sender, EventArgs e)
    {
        applicant();
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {

    }
    #endregion

    #region 列表绑定
    private void ListBind()
    {
        DataSet ds = DbHelperSQL.ExecuteDataSet("select [Pk_EduLevelId],[EduLevel] from EduLevel");
        this.drpEduLevel.DataSource=ds;
        this.drpEduLevel.DataTextField=ds.Tables[0].Columns[1].ToString();
        this.drpEduLevel.DataValueField = ds.Tables[0].Columns[0].ToString();
        this.drpEduLevel.DataBind();
    }
    #endregion

    #region 提交信息
    private void applicant()
    {
        JXMSTC2.Model.EduApplicant eap = new JXMSTC2.Model.EduApplicant();
        EduApplicatModelControl eapcon = new EduApplicatModelControl();

        eap.ApplicantName = txtName.Text;
        if (txtBrithday.Text != "")
        {
            eap.Birthdate = Convert.ToDateTime(txtBrithday.Text);
        }
        eap.EmailBox = txtEmail.Text;
        eap.Fk_EduLevelId = Convert.ToInt32(drpEduLevel.SelectedValue);
        eap.Gender = Convert.ToBoolean(drpSex.SelectedValue);
        eap.MSN = txtMSN.Text;
        eap.QQ = txtQQ.Text;
        eap.Phone = txtTel.Text;
        eap.PostAddress = txtAddress.Text;
        eap.PostCode = txtPostCode.Text;
        eap.State = 0;
        eap.Fk_NewClassId = Convert.ToInt16(Request["classID"]);

        int i=eapcon.Add(eap);
        MessageBox.Show(Page, i.ToString());
    }
    #endregion
}
